package com.mvp.dagger.translate.mvp.presenter;

import android.content.SharedPreferences;

import com.mvp.dagger.translate.MainActivity;
import com.mvp.dagger.translate.base.OnHttpCallBack;
import com.mvp.dagger.translate.bean.TranslateResult;
import com.mvp.dagger.translate.mvp.contract.MainContract;
import com.mvp.dagger.translate.mvp.model.MainModel;

import java.util.Map;

import javax.inject.Inject;

public class MainPresenter implements MainContract.Presenter {

    private final MainActivity view;
    private final MainModel model;

    @Inject
    public MainPresenter(MainActivity view, MainModel model) {
        this.view = view;
        this.model = model;
    }
    @Override
    public void getTranslate(Map<String, String> names) {

        model.getTranslate(names, new OnHttpCallBack<TranslateResult>() {
            @Override
            public void onSuccessful(TranslateResult o) {
                view.getTranslateSuccess(o);
            }

            @Override
            public void onFail(String errorMsg) {
                view.getTranslateFail(errorMsg);
            }

            @Override
            public void onOver() {

            }
        });
    }
}
